﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.ModFlow.Domain.DomainLayer
{
    [Serializable]
    public  class Drain:MFPointSC,ICloneable
    {

       public Drain(int i, int j, int k, int nrows, int ncolumns, int nlayers,int nPeriods)
            : base(i, j, k,nrows,ncolumns,nlayers,nPeriods)
        {

            this._conductance = new List<double>();


            this._elevation = new List<double>();

            for (int m = 0; m < nPeriods; m++)
            {
               
                this._conductance.Add(0);
                this._elevation.Add(0);

            }
         

        }

       public Drain(int index, int nrows, int ncolumns, int nlayers, int nPeriods)
            : base(index, nrows, ncolumns, nlayers,nPeriods)
        {


            this._conductance = new List<double>();


            this._elevation = new List<double>();

            for (int m = 0; m < nPeriods; m++)
            {
               
                this._conductance.Add(0);
                this._elevation.Add(0);

            }

 
        }




       List<double> _conductance;

       public List<double> Conductance
       {
           get { return _conductance; }

       }


       public double FirstConductance
       {

           get
           {

               return this._conductance[0];


           }

           set
           {
               this._conductance[0] = value;
           }

       }




       List<double> _elevation;

       public List<double> Elevation
       {
           get { return _elevation; }

       }

       public double FirstElevation
       {


           get
           {

               return this._elevation[0];


           }

           set
           {
               this._elevation[0] = value;
           }

       }
       



        public object Clone()
        {
            Drain drain = (Drain)this.MemberwiseClone();

            drain._elevation = new List<double>();
            drain._conductance = new List<double>();




            drain.Elevation.AddRange(this.Elevation);

            drain.Conductance.AddRange(this.Conductance);



            return drain;

        }
        public override void OnResetSperiods(int nPeriods)
        {
            base.OnResetSperiods(nPeriods);

            if (this.NPeriods == nPeriods)
            {
                return;

            }

            if (this.NPeriods < nPeriods)
            {
                int nSub = nPeriods - this.NPeriods;
                for (int i = 0; i < nSub; i++)
                {
                    this.Conductance.Add(this.Conductance[0]);
                    this.Elevation.Add(this.Elevation[0]);
                }
            }

            else
            {
                int nSub = this.NPeriods - nPeriods;
                this.Conductance.RemoveRange(nPeriods, nSub);
                this.Elevation.RemoveRange(nPeriods, nSub);
            }

            this.NPeriods = nPeriods;

        }
      
    }
}
